package com.winsomely.leecode;

/**
 * 数字 1 的个数
 * 
 * @author liujiawei
 *
 */
public class MoveZeroes {

	/**
	 * 0,1,0,3,1, 2 1,1,0,3,1, 2 1,1,3,3,1, 2
	 * 
	 * 
	 * @param nums
	 * @return
	 */
	public void moveZeroes(int[] nums) {
		if (nums.length == 1) {
			return;
		}
		int b = 0, e = 0;
		while (e < nums.length) {
			if (nums[e] != 0) {
				int temp = nums[b];
				nums[b] = nums[e];
				nums[e] = temp;
				b++;
			}
			e++;
		}
	}

	public static void main(String[] args) {
		MoveZeroes t = new MoveZeroes();
		int[] nums = { 2, 0, 1, 0, 0, 0, 3, 4, 0, 7, 0, 0 };
		t.moveZeroes(nums);
		for (int i = 0; i < nums.length; i++) {
			System.out.print(nums[i] + ", ");
		}
	}

}
